<!DOCTYPE html>
<html>
	<head>
		<meta content="text/html; charset=UTF-8" http-equiv="Content-Type" />
		<meta content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" name="viewport" />
		<meta content="telephone=no" name="format-detection" />
		<meta content="address=no" name="format-detection" />
		<meta name="apple-mobile-web-app-capable" content="no" />
		<link rel="apple-touch-icon-precomposed" href="http://img0.zz91.com/zz91/images/logo.png" />
		<link rel="apple-touch-icon-precomposed" sizes="114x114" href="apple-touch-icon-precomposed" />
		<meta name="apple-touch-fullscreen" content="YES">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">
		<link rel="shortcut icon" href="http://img0.zz91.com/front/favicon.ico" />
		<title></title>
		<link rel="stylesheet" type="text/css" href="/layui/css/layui.css"/>	
		<script type="text/javascript" src="/layui/layui.js"></script>
		<style>
			.mainbox{
				margin: 10px;
			}
		</style>
	</head>
	<body>
		<div class="mainbox">
			<div class="demoTable">
				姓名：
			  	<div class="layui-inline">
			    	<input class="layui-input" name="name" id="name" autocomplete="off">
			  	</div>
			  	<button class="layui-btn layui-btn-normal" data-type="reload">查询</button>
			  	<a href="user_add.html" class="layui-btn layui-btn-primary">添加</a>
			</div>
			 
			<table class="layui-hide" id="LAY_table_user" lay-filter="user"></table> 
		</div>
		<script id="barcaozuo" type="text/html">
		  <a class="layui-btn layui-btn-mini" lay-event="edit">编辑</a>
		  <a class="layui-btn layui-btn-danger layui-btn-mini" lay-event="del">删除</a>
		</script>
		<script src="js/jquery.js" charset="utf-8"></script>
		<script src="js/comm.js" charset="utf-8"></script>
	</body>
	
	<script>
		layui.use('table', function(){
		  var table = layui.table;
		  var $ = layui.$;
		  //方法级渲染
		  function tablerender(){table.render({
		    elem: '#LAY_table_user'
		    ,url: 'user_data.html?name='+$("#name").val()
		    ,cols: [[
		      {checkbox: true, fixed: true}
		      ,{field:'id', title: '序号', width:150, fixed: true, edit: 'text'}
		      ,{field:'groupname', title: '集团名称', width:150, edit: 'text'}
		      ,{field:'companyname', title: '分公司名称', width:150, edit: 'text'}
		      ,{field:'utype', title: '用户类别', width:100, edit: 'text'}
		      ,{field:'username', title: '用户名', width:100, edit: 'text'}
		      ,{field:'contact', title: '姓名', width:100, edit: 'text'}
		      ,{field:'sex', title: '性别', width:120, edit: 'text'}
		      ,{field:'mobile', title: '手机', width:120, edit: 'text'}
		      ,{field:'bz', title: '备注', width:200, edit: 'text'}
		      ,{field:'caozuo', title: '操作', width:200, edit: 'text',toolbar:'#barcaozuo'}
		    ]]
		    ,id: 'testReload'
		    ,page: true
		    ,limit: 10
		    ,limits:[]
		    ,height: 500
		  })};
		  tablerender();
		  
		  //监听工具条
		  table.on('tool(user)', function(obj){
		    var data = obj.data;
		    if(obj.event === 'del'){
		      layer.confirm('真的删除行么', function(index){
		        data={id:data.id};
		        crmajax('post','user_del.html',data,function(){obj.del();},function(){});
		        layer.close(index);
		      });
		    } else if(obj.event === 'edit'){
		    	window.location='user_mod.html?id='+data.id;
		      //layer.alert('编辑行：<br>'+ JSON.stringify(data))
		    };
		  });
		  
		  $('.demoTable .layui-btn-normal').on('click', function(){
				tablerender();
		  });
		  
		});
	</script>
</html>
